﻿using System;
using eCommerce.DataAccess;

namespace eCommerce.Site.Controls
{
    public partial class Menu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            litMenu.Text = "";
            using (SiteProductsDataContext siteProductsDataContext = new SiteProductsDataContext())
            {
                foreach (var row1 in siteProductsDataContext.getCategoryType())
                {
                    litMenu.Text += "<li><a id=\"lnkbtn" + row1.CategoryName +
                                   "\" class=\"home\" href='Product.aspx?c=" + row1.CategoryID +
                                   "' runat=\"server\">" + row1.CategoryName + "</a>";

                    litMenu.Text += "<div class=\"sub\"><ul>";
                    foreach (var row in siteProductsDataContext.getMenubyCategoryTypebyCatID(row1.CategoryID))
                    {
                        litMenu.Text += "<li><a href=\"Product.aspx?t=" +
                                        row.ProductTypeID + "\">" + row.ProductType + "</a></li>";
                    }
                    litMenu.Text += "</ul></div>";
                    litMenu.Text += "</li>";


                }
            }


        }
    }
}